package pe.gob.inei.sirtod.domain;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;

import pe.gob.inei.sirtod.domain.pk.DatoTrimestralPk;
import pe.gob.inei.sirtod.util.DomainBase;

@Entity
@NamedNativeQueries(
	@NamedNativeQuery(name = "DatoTrimestral.findAll", query = "SELECT D_T.ANIO, D.ID_DEPARTAMENTO, D.DES_DEPARTAMENTO, "
		+ "D_T.INDICADOR_ID, MAX(T_1) AS T01, MAX(T_2) AS T02, MAX(T_3) AS T03, MAX(T_4) AS T04 FROM "
		+ " SIDIN_CONSULTA.DATO_TRIM_DEP D_T LEFT OUTER JOIN SIDIN_CONSULTA.DEPARTAMENTO D ON "
		+ "D_T.ID_DEPARTAMENTO = D.ID_DEPARTAMENTO WHERE D.ID_DEPARTAMENTO IN (:lisDepSel) AND "
		+ "D_T.INDICADOR_ID IN (:lisIndSel) AND D_T.ANIO BETWEEN :txtAniIni AND :txtAniFin GROUP "
		+ "BY D_T.ANIO, D.ID_DEPARTAMENTO, D.DES_DEPARTAMENTO, D_T.INDICADOR_ID ORDER BY D.ID_DEPARTAMENTO, "
		+ "D_T.ANIO, D_T.INDICADOR_ID", resultClass = DatoTrimestral.class))
@SuppressWarnings("serial")
public class DatoTrimestral implements DomainBase {

	@EmbeddedId
	private DatoTrimestralPk pk;

	@Column(name = "DES_DEPARTAMENTO")
	private String departamento;

	@Column(name = "T01")
	private String valor01;

	@Column(name = "T02")
	private String valor02;

	@Column(name = "T03")
	private String valor03;

	@Column(name = "T04")
	private String valor04;

	public String getValue(int txtPerSel) {
		switch(txtPerSel) {
			case 1: return valor01;
			case 2: return valor02;
			case 3: return valor03;
			case 4: return valor04;
		}
		return null;
	}
	
	public String getPeriodo() {
		return pk.getPeriodo();
	}
	
	public Integer getIndicadorId() {
		return pk.getIndicadorId();
	}

	public DatoTrimestralPk getPk() {
		return pk;
	}

	public void setPk(DatoTrimestralPk pk) {
		this.pk = pk;
	}

	public String getDepartamento() {
		return departamento;
	}

	public void setDepartamento(String departamento) {
		this.departamento = departamento;
	}

	public String getValor01() {
		return valor01;
	}

	public void setValor01(String valor01) {
		this.valor01 = valor01;
	}

	public String getValor02() {
		return valor02;
	}

	public void setValor02(String valor02) {
		this.valor02 = valor02;
	}

	public String getValor03() {
		return valor03;
	}

	public void setValor03(String valor03) {
		this.valor03 = valor03;
	}

	public String getValor04() {
		return valor04;
	}

	public void setValor04(String valor04) {
		this.valor04 = valor04;
	}
}